package com.peanut.baby.http;

import com.peanut.baby.model.Ad;
import com.peanut.baby.model.Advice;
import com.peanut.baby.model.AppMsg;
import com.peanut.baby.model.BBSComment;
import com.peanut.baby.model.BBSMoment;
import com.peanut.baby.model.CalendarRecord;
import com.peanut.baby.model.CircleTrends;
import com.peanut.baby.model.DailySign;
import com.peanut.baby.model.Feedback;
import com.peanut.baby.model.HomeData;
import com.peanut.baby.model.InitialAd;
import com.peanut.baby.model.LiveGroupAll;
import com.peanut.baby.model.LiveGroupRel;
import com.peanut.baby.model.LiveMsg;
import com.peanut.baby.model.LiveRoom;
import com.peanut.baby.model.MomentRel;
import com.peanut.baby.model.MyTag;
import com.peanut.baby.model.PTag;
import com.peanut.baby.model.PointHistory;
import com.peanut.baby.model.QA;
import com.peanut.baby.model.QAComment;
import com.peanut.baby.model.QaRel;
import com.peanut.baby.model.Record;
import com.peanut.baby.model.SearchResultBundle;
import com.peanut.baby.model.UploadConf;
import com.peanut.baby.model.User;
import com.peanut.baby.model.VarPoint;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

/**
 * Created by anonymouslystudio on 2017/6/6.
 */

public interface APIInterface {
    //@FormUrlEncoded
    @FormUrlEncoded
    @POST("/i/config/getParam")
    Observable<BaseResponse<String>> getConfigParam(@Field("id") int id);

    //get identify code

    @FormUrlEncoded
    @POST("/i/user/mobileLogin")
    Observable<BaseResponse<User>> login(@Field("mobile") String mobile,
                                         @Field("vcode") String vcode);

    @FormUrlEncoded
    @POST("/i/user/mobileLoginTest")
    Observable<BaseResponse<User>> testLogin(@Field("mobile") String mobile);

    @FormUrlEncoded
    @POST("/i/user/appBindMobile")
    Observable<BaseResponse<User>> bindMobile(@Field("userId") String userId,
                                              @Field("mobile") String mobile,
                                              @Field("vcode") String vcode);

    @FormUrlEncoded
    @POST("/i/user/thirdPartLogin")
    Observable<BaseResponse<User>> sdkLogin(@Field("openid") String openid,
                                            @Field("accesstoken") String accesstoken,
                                            @Field("expiresIn") String expiresIn,
                                            @Field("type") String type,
                                            @Field("uuid") String uuid,
                                            @Field("idfa") String idfa,
                                            @Field("mac") String mac,
                                            @Field("ipAddress") String ipAddress,
                                            @Field("device") String device,
                                            @Field("osversion") String osversion,
                                            @Field("model") String model,
                                            @Field("version") String version,
                                            @Field("screen") String screen,
                                            @Field("network") String network,
                                            @Field("timestamp") String timestamp,
                                            @Field("nickname") String nickname,
                                            @Field("avatar") String avatar,
                                            @Field("gender") String gender,
                                            @Field("province") String province,
                                            @Field("city") String city,
                                            @Field("country") String country,
                                            @Field("unionid") String unionid);


    @FormUrlEncoded
    @POST("/i/user/bindWeixin")
    Observable<BaseResponse<User>> bindWeixin(@Field("userId") String userId,
                                              @Field("userToken") String userToken,
                                              @Field("accesstoken") String accesstoken,
                                              @Field("expiresIn") String expiresIn,
                                              @Field("openid") String openid,
                                              @Field("unionid") String unionid);


    @FormUrlEncoded
    @POST("/i/user/update")
    Observable<BaseResponse<User>> updateUserInfo(@FieldMap Map<String, String> map);

    @FormUrlEncoded
    @POST("/i/user/updateStatus")
    Observable<BaseResponse<User>> updateStatus(@Field("userStatus") int userStatus,
                                                @Field("userId") String userId,
                                                @Field("userToken") String userToken);


    @FormUrlEncoded
    @POST("/i/fc/uploadToken")
    Observable<BaseResponse<List<UploadConf>>> getUploadToken(@Field("objectNames") String fileNameInBucket,
                                                              @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/live/roomList")
    Observable<BaseResponse<List<LiveRoom>>> getLiveRoomList(@Field("userId") String userId,
                                                             @Field("pageNo") int pageNo,
                                                             @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/live/getEnrolList")
    Observable<BaseResponse<List<LiveRoom>>> getSelfLiveRoomList(@Field("userId") String userId,
                                                             @Field("pageNo") int pageNo,
                                                             @Field("pageSize") int pageSize,
                                                                 @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/live/expertRoomList")
    Observable<BaseResponse<List<LiveRoom>>> getExpertLiveRoomList(@Field("expertId") String userId,
                                                                   @Field("userToken") String userToken,
                                                                   @Field("pageNo") int pageNo,
                                                                   @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/live/roomInfo")
    Observable<BaseResponse<LiveRoom>> getLiveRoomInfo(@Field("userId") String userId,
                                                       @Field("roomId") String roomId);

    @FormUrlEncoded
    @POST("/i/live/entrol")
    Observable<BaseResponse<String>> enroleLiveRoom(@Field("userToken") String userToken,
                                                    @Field("userId") String userId,
                                                    @Field("roomId") String roomId);

    @FormUrlEncoded
    @POST("/i/live/entrol2")
    Observable<BaseResponse<String>> enroleLiveRoom2(@Field("userToken") String userToken,
                                                    @Field("userId") String userId,
                                                    @Field("roomId") String roomIds, @Field("points") String points);

    @FormUrlEncoded
    @POST("/i/user/pregnantAdvice")
    Observable<BaseResponse<Advice>> getAdvice(@Field("userToken") String userToken,
                                               @Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/live/messageList")
    Observable<BaseResponse<List<LiveMsg>>> getLiveRoomMessages(@Field("userToken") String userToken,
                                                                @Field("roomId") String roomId,
                                                                @Field("lastMessageId") String lastMessageId);

    @FormUrlEncoded
    @POST("/i/live/messageList2")
    Observable<BaseResponse<List<LiveMsg>>> getLiveRoomMessagesByGroupId(@Field("userToken") String userToken,
                                                                @Field("groupId") String groupId);

    @FormUrlEncoded
    @POST("/i/live/getLiveRoomsByGroupId")
    Observable<BaseResponse<List<LiveGroupRel>>> getLiveRoomsByGroupId(@Field("groupId") String groupId);


    @FormUrlEncoded
    @POST("/i/live/sendMessage")
    Observable<BaseResponse<LiveMsg>> sendLiveRoomMessages(@Field("userToken") String userToken,
                                                           @Field("roomId") String roomId,
                                                           @Field("type") String type,
                                                           @Field("messageType") String messageType,
                                                           @Field("message") String message);

    @FormUrlEncoded
    @POST("/i/live/list")
    Observable<BaseResponse<HomeData>> getHomeData(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/live/livegroupall")
    Observable<BaseResponse<LiveGroupAll>> getLiveGroupAll(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/push/infoUpload")
    Observable<BaseResponse<String>> uploadPushToken(@Field("userToken") String userToken,
                                                     @Field("userId") String userId,
                                                     @Field("clientType") int clientType,
                                                     @Field("clientId") String clientId);

    @FormUrlEncoded
    @POST("/i/qa/list")
    Observable<BaseResponse<List<QA>>> getQaList(@Field("userId") String userId,
                                                 @Field("pageNo") int pageNo,
                                                 @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/qa/myQuestionlist")
    Observable<BaseResponse<List<QA>>> getUserQaList(@Field("userId") String userId,
                                                     @Field("pageNo") int pageNo,
                                                     @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/qa/expertAnswerlist")
    Observable<BaseResponse<List<QA>>> getExpertQaList(@Field("expertId") String expertId,
                                                       @Field("userToken") String userToken,
                                                       @Field("pageNo") int pageNo,
                                                       @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/qa/submitQuestion")
    Observable<BaseResponse<List<QA>>> submitQuestion(@Field("title") String title,
                                                      @Field("type") String type,
                                                      @Field("userId") String userId,
                                                      @Field("description") String description,
                                                      @Field("imageUrl") String imageUrl,
                                                      @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/qa/detail")
    Observable<BaseResponse<QA>> getQaDetail(@Field("id") String id,
                                             @Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/qa/search")
    Observable<BaseResponse<List<QA>>> searchQA(@Field("searchText") String searchText,
                                                @Field("pageNo") int pageNo,
                                                @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/search")
    Observable<BaseResponse<SearchResultBundle>> search(@Field("searchText") String searchText, @Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/qa/submitAnswer")
    Observable<BaseResponse<QA>> answerQuestion(@Field("id") String questionId,
                                                @Field("userId") String userId,
                                                @Field("audioUrl") String audioUrl,
                                                @Field("duration") long duration,
                                                @Field("userToken") String userToken,
                                                @Field("doctorId") String doctorId);

    @FormUrlEncoded
    @POST("/i/qa/comment")
    Observable<BaseResponse<QAComment>> commentQA(@Field("id") String questionId,
                                                  @Field("userId") String userId,
                                                  @Field("contentType") String contentType,
                                                  @Field("userToken") String userToken,
                                                  @Field("content") String content);

    @FormUrlEncoded
    @POST("/i/qa/praise")
    Observable<BaseResponse<QA>> praiseQA(@Field("id") String questionId,
                                          @Field("userId") String userId,
                                          @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/qa/commentList")
    Observable<BaseResponse<List<QAComment>>> getQaCommentList(@Field("id") String questionId,
                                                               @Field("pageNo") int pageNo,
                                                               @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/qa/playAnswerAudio")
    Observable<BaseResponse<String>> getQaAnswerAudio(@Field("id") String questionId,
                                                      @Field("userId") String userId,
                                                      @Field("userToken") String userToken);

    //----------圈子-----------
    @FormUrlEncoded
    @POST("/i/circle/talentAdvice")
    Observable<BaseResponse<List<User>>> getCircleFamousPerson(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/circle/userCommentList")
    Observable<BaseResponse<List<BBSComment>>> getUserCommentedMoments(@Field("userId") String userId,
                                                                       @Field("pageNo") int pageNo,
                                                                       @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/circle/concern")
    Observable<BaseResponse<User>> changeFollowStatus(@Field("userId") String userId,
                                                      @Field("concernedId") String concernedId,
                                                      @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/circle/friendPost")
    Observable<BaseResponse<List<BBSMoment>>> getFollowingMoments(@Field("userId") String userId,
                                                                  @Field("pageNo") int pageNo,
                                                                  @Field("pageSize") int pageSize,
                                                                  @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/circle/userPost")
    Observable<BaseResponse<List<BBSMoment>>> getUserMoments(@Field("userId") String userId,
                                                             @Field("pageNo") int pageNo,
                                                             @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/circle/submitPost")
    Observable<BaseResponse<BBSMoment>> submitMoment(@Field("userId") String userId,
                                                     @Field("type") String type,
                                                     @Field("title") String title,
                                                     @Field("content") String content,
                                                     @Field("imgUrl") String imgUrl,
                                                     @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/circle/submitTrend ")
    Observable<BaseResponse<BBSMoment>> submitMomentNew(@Field("userId") String userId,
                                                     @Field("type") String type,

                                                     @Field("content") String content,
                                                     @Field("imgUrl") String imgUrl,
                                                     @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/circle/postInfo")
    Observable<BaseResponse<BBSMoment>> getMomentDetail(@Field("id") String id,@Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/circle/talentInfo")
    Observable<BaseResponse<User>> getFamousInfo(@Field("talentId") String talentId,
                                                 @Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/user/doctorInfo")
    Observable<BaseResponse<User>> getDoctorInfo(@Field("doctorId") String userId,
                                                 @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/circle/postCommentList")
    Observable<BaseResponse<List<BBSComment>>> getMomentComments(@Field("id") String momentId,
                                                                 @Field("pageNo") int pageNo,
                                                                 @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/circle/comment")
    Observable<BaseResponse<BBSComment>> sendBBSComment(@Field("id") String id,
                                                        @Field("userId") String userId,
                                                        @Field("contentType") int type,
                                                        @Field("title") String title,
                                                        @Field("content") String content,
                                                        @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/circle/hotpost")
    Observable<BaseResponse<List<BBSMoment>>> getHotMoments(@Field("flag") int flag,
                                                            @Field("pageNo") int pageNo,
                                                            @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/circle/allpost")
    Observable<BaseResponse<List<BBSMoment>>> getAllMoments(@Field("pageNo") int pageNo,
                                                            @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/circle/trendList")
    Observable<BaseResponse<List<BBSMoment>>> getTrendList(@Field("pageNo") int pageNo,
                                                            @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("/i/circle/userFansList")
    Observable<BaseResponse<List<User>>> getUserFans(@Field("userId") String userId,
                                                     @Field("pageNo") int pageNo,
                                                     @Field("pageSize") int pageSize,
                                                     @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/circle/userConcernList")
    Observable<BaseResponse<List<User>>> getUserFollowings(@Field("userId") String userId,
                                                           @Field("pageNo") int pageNo,
                                                           @Field("pageSize") int pageSize,
                                                           @Field("userToken") String userToken);

    //---- 我的页面----//
    @FormUrlEncoded
    @POST("/i/user/myInfo")
    Observable<BaseResponse<User>> getMyInfo(@Field("userId") String userId);
    @FormUrlEncoded
    @POST("/i/user/pointHistory")
    Observable<BaseResponse<List<PointHistory>>> getPointHistory(@Field("userId") String userId,
                                                                 @Field("pageNo") int pageNo,
                                                                 @Field("pageSize") int pageSize,
                                                                 @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/feedback/submit")
    Observable<BaseResponse<Feedback>> feedback(@Field("userId") String userId,
                                                @Field("feedback") String feedback,
                                                @Field("contact") String contact,
                                                @Field("userToken") String userToken);

    //---- 首页 ---//
    @FormUrlEncoded
    @POST("/i/user/dailySign")
    Observable<BaseResponse<DailySign>> dailySign(@Field("userId") String userId,
                                                  @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/user/pushMessageList")
    Observable<BaseResponse<List<AppMsg>>> getPushMessages(@Field("userId") String userId,
                                                           @Field("pageNo") int pageNo,
                                                           @Field("pageSize") int pageSize,
                                                           @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/user/pushMessageRead")
    Observable<BaseResponse<String>> setMessageReaded(@Field("id") String msgId,
                                                      @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/userLog/submitDaily")
    Observable<BaseResponse<CalendarRecord>> submitDailyRecord(@Field("userId") String userId,
                                                               @Field("date") String date,
                                                               @Field("logA") String logA,
                                                               @Field("logB") String logB,
                                                               @Field("logC") String logC,
                                                               @Field("logD") String logD,
                                                               @Field("logE") String logE,
                                                               @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/userLog/dailyList")
    Observable<BaseResponse<List<CalendarRecord>>> getMyData(@Field("userId") String userId,
                                                             @Field("pageNo") int pageNo,
                                                             @Field("pageSize") int pageSize,
                                                             @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/userLog/dailyListIndex")
    Observable<BaseResponse<List<CalendarRecord>>> getDaliyRecords(@Field("userId") String userId,
                                                                   @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/userLog/submiMedical")
    Observable<BaseResponse<Record>> submitZhenliao(@Field("userId") String userId,
                                                    @Field("type") String type,
                                                    @Field("desc") String desc,
                                                    @Field("imgUrl") String imgUrl,
                                                    @Field("userToken") String userToken);
    @FormUrlEncoded
    @POST("/i/userLog/medicalList")
    Observable<BaseResponse<List<Record>>> getZhenliaoList(@Field("pageNo") int pageNo,
                                                           @Field("pageSize") int pageSize,
                                                           @Field("userId") String userId,
                                                           @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/userLog/careList")
    Observable<BaseResponse<List<Record>>> getTiaolliList(@Field("pageNo") int pageNo,
                                                          @Field("pageSize") int pageSize,
                                                          @Field("userId") String userId,
                                                          @Field("userToken") String userToken);
    @FormUrlEncoded
    @POST("/i/userLog/submiCare")
    Observable<BaseResponse<Record>> submitTiaoli(@Field("userId") String userId,
                                                  @Field("type") String type,
                                                  @Field("desc") String desc,
                                                  @Field("imgUrl") String imgUrl,
                                                  @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/point/share")
    Observable<BaseResponse<VarPoint>> sharePoint(@Field("userId") String userId,
                                                  @Field("shareType") String shareType, //105帖子、106直播、107问答、108App
                                                  @Field("objectId") String objectId);

    @FormUrlEncoded
    @POST("/i/banner/list")
    Observable<BaseResponse<List<Ad>>> getBannerList(@Field("location") int location);

    @FormUrlEncoded
    @POST("/i/circle/circleTrend")
    Observable<BaseResponse<CircleTrends>> getCircleTrends(@Field("userId") String userId,
                                                           @Field("userToken") String userToken);


    @FormUrlEncoded
    @POST("/i/userTag/userTagList")
    Observable<BaseResponse<List<PTag>>> getSubscribedTagList(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/userTag/tagList")
    Observable<BaseResponse<List<PTag>>> getTagList(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/userTag/updateUserTag")
    Observable<BaseResponse<List<PTag>>> subscribeTag(@Field("userId") String userId,
                                                      @Field("tagIdList") List<Integer> tagIds,
                                                      @Field("userToken") String userToken);


    @FormUrlEncoded
    @POST("/i/circle/postRel")
    Observable<BaseResponse<MomentRel>> getPostRel(@Field("id") String id,
                                                   @Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/qa/qaRel")
    Observable<BaseResponse<QaRel>> getQaRel(@Field("id") int id,
                                             @Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/gg/get")
    Observable<BaseResponse<InitialAd>> getInitialAd(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("/i/tags/refresh")
    Observable<BaseResponse<List<String>>> getHotTags(@Field("userId") String userId);

    @POST("/i/live/searchPageHot")
    Observable<BaseResponse<List<QA>>> searchPageHot();

    @FormUrlEncoded
    @POST("/i/tags/getMyTags")
    Observable<BaseResponse<MyTag>> getRecommendTags(@Field("userId") String userId, @Field("userToken") String userToken);

    @FormUrlEncoded
    @POST("/i/tags/setMyTags")
    Observable<BaseResponse<String>> setTabsSubscribe(@Field("userId") String userId,@Field("tags") String tags,@Field("userToken") String userToken);

}
